<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script type="text/javascript">
$(function(){
	//初始化表单验证
	$("#addForm").validate({
		rules:{link:{url:true}},
		messages:{
			link: {required: "请输入正确的链接地址"},
			goodsid:{required: "请输入正确的商品ID"}
		},
		submitHandler:function(form){
			$(form).ajaxSubmit({
				success:function(data){
					switch(data.flag){
					case 1:
						Kit.alert("请上传图片");return;
					case -1:
						Kit.alert("网络繁忙...，请重试");return;
					case 0:
						onAddSuccess(data.object);
						addDialog.close();
					}
				}
			});
		}
	});
	$("#validtime2").hide();
	$(".validtime").click(function() {
		var v = $('input[name="validtime0"]').filter(':checked').val();
		if (v == 1) {
			$("#validtime1").show();
			$("#validtime2").hide();
		} else if (v == 2) {
			$("#validtime1").hide();
			$("#validtime2").show();
		}
	});
});

</script>
<form id="addForm" action="${BASE_PATH}/bus/ad/doAdd" method="post" class="form-horizontal" enctype="multipart/form-data">
	<div class="form-group">
		<label class="col-lg-3 control-label">图片</label>
		<div class="col-lg-8">
			<input type="file" id="thumb" name="thumb" accept="image/jpg,image/png" title="选择文件">
		</div>
		<div class="col-sm-8" style="margin-left: 110px;margin-top: 10px;"><span style="margin-right:10px; color:red;">***</span><span class="text-success">图片已尺寸宽750*高375为最佳</span></div>
	</div>
	<div class="form-group">
		<label class="col-lg-3 control-label">商品/活动</label>
		<div class="col-lg-8 validtime">
			<label><input name="validtime0" type="radio" value="1" checked />普通商品</label> 
			<label><input name="validtime0" type="radio" value="2" />活动 </label>
		</div>
	</div>
	<div id="validtime1" class="form-group">
	    <label class="col-lg-3 control-label">商品ID</label>
	    <div class="col-lg-8">
        	<input type="text" name="goodsid" value="" class="form-control" placeholder="请输入商品ID" maxlength="200" required>
	    </div>
	</div>
	<div id="validtime2" class="form-group">
	    <label class="col-lg-3 control-label">链接</label>
	    <div class="col-lg-8">
        	<input type="text" name="link" value="" class="form-control" placeholder="请输入链接地址" maxlength="200" required>
	    </div>
	</div>
	<div  class="form-group">
	    <label class="col-lg-3 control-label">轮播背景色</label>
	    <div class="col-lg-8">
        	<input type="text" name="background" value="" class="form-control" placeholder="请输入轮播背景色RGB编码 例如：#F04844" maxlength="200" required>
	    </div>
	</div>
	<div class="row">
		<div class="col-lg-6"><button class="btn btn-primary col-sm-3 pull-right" type="submit" autocomplete="off">提交</button></div>
		<div class="col-lg-6"><button class="btn btn-default col-sm-3 pull-left" type="button" onclick="javascript:addDialog.close();" autocomplete="off">取消</button></div>
	</div>
</form>